{% extends "base.html" %}

{% block content %}
<div class="container-fluid">
    <div class="card">
        <div class="card-header">
            <h5 class="mb-0"><i class="fas fa-edit me-2"></i>编辑管网</h5>
        </div>
        <div class="card-body">
            <form method="POST" action="{{ url_for('network.network_edit', id=pipe.id) }}">
                <div class="row g-3">
                    <div class="col-md-6">
                        <label for="name" class="form-label">管网名称</label>
                        <input type="text" class="form-control" id="name" name="name" value="{{ pipe.name }}" required>
                    </div>
                    <div class="col-md-6">
                        <label for="pipe_type" class="form-label">管道类型</label>
                        <select class="form-select" id="pipe_type" name="pipe_type" required>
                            <option value="main" {% if pipe.pipe_type == 'main' %}selected{% endif %}>主管</option>
                            <option value="branch" {% if pipe.pipe_type == 'branch' %}selected{% endif %}>支管</option>
                        </select>
                    </div>
                    <div class="col-md-6">
                        <label for="material" class="form-label">管道材质</label>
                        <input type="text" class="form-control" id="material" name="material" value="{{ pipe.material }}" required>
                    </div>
                    <div class="col-md-3">
                        <label for="diameter" class="form-label">管径(mm)</label>
                        <input type="number" step="0.1" class="form-control" id="diameter" name="diameter" value="{{ pipe.diameter }}" required>
                    </div>
                    <div class="col-md-3">
                        <label for="length" class="form-label">长度(m)</label>
                        <input type="number" step="0.1" class="form-control" id="length" name="length" value="{{ pipe.length }}" required>
                    </div>
                    <div class="col-md-6">
                        <label for="start_point" class="form-label">起点位置</label>
                        <input type="text" class="form-control" id="start_point" name="start_point" value="{{ pipe.start_point }}" required>
                    </div>
                    <div class="col-md-6">
                        <label for="end_point" class="form-label">终点位置</label>
                        <input type="text" class="form-control" id="end_point" name="end_point" value="{{ pipe.end_point }}" required>
                    </div>
                    <div class="col-md-6">
                        <label for="installation_date" class="form-label">安装日期</label>
                        <input type="date" class="form-control" id="installation_date" name="installation_date" value="{{ pipe.installation_date.strftime('%Y-%m-%d') }}" required>
                    </div>
                    <div class="col-md-6">
                        <label for="status" class="form-label">状态</label>
                        <select class="form-select" id="status" name="status" required>
                            <option value="normal" {% if pipe.status == 'normal' %}selected{% endif %}>正常</option>
                            <option value="maintenance" {% if pipe.status == 'maintenance' %}selected{% endif %}>维修中</option>
                            <option value="scrapped" {% if pipe.status == 'scrapped' %}selected{% endif %}>已报废</option>
                        </select>
                    </div>
                    <div class="col-12">
                        <label for="description" class="form-label">描述</label>
                        <textarea class="form-control" id="description" name="description" rows="3">{{ pipe.description }}</textarea>
                    </div>
                    <div class="col-12">
                        <div class="d-flex justify-content-between">
                            <a href="{{ url_for('network.network_index') }}" class="btn btn-secondary">
                                <i class="fas fa-arrow-left me-1"></i>返回
                            </a>
                            <button type="submit" class="btn btn-primary">
                                <i class="fas fa-save me-1"></i>保存
                            </button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
{% endblock %} 